using System;
using System.Collections.Generic;
using System.Text;

namespace RapidHDL.Fabric
{
    public class Output
    {
        NodeVector nvNodeVector;
        string sName;
        int iWidth;

        Block bkParentBlock;

        public Output(Block pbkParentBlock,string psName, int piWidth)
        {
            iWidth = piWidth;
            bkParentBlock = pbkParentBlock;
            sName = psName;
        }

        internal void LinkNodeVector(NodeVector pnvNodeVector)
        {
            nvNodeVector = pnvNodeVector;
        }

        public int Width
        {
            get { return iWidth; }
            set { iWidth = value; }
        }

        public NodeVector NodeVector
        {
            get { return nvNodeVector; }
        }

        public string Name
        {
            get { return sName; }
        }

        public string FullName
        {
            get { return this.ToString().Replace('.','_');}
        }

        public override string ToString()
        {
            return bkParentBlock.ToString() + "." + sName;
        }

        internal string ValidateStructure()
        {
            string sError = "";
            if (nvNodeVector == null)
                return SharedUtility.BuildError(this.ToString(),"Node Vector Is Null");
            if (iWidth != nvNodeVector.Width)
                return SharedUtility.BuildError(this.ToString(), "Node Vector Width is " + nvNodeVector.Width.ToString() + ", Expected " + iWidth.ToString());
            return "";
        }
    }
}
